Types in MathNet.Numerics.LinearAlgebra
Public Static Functions
Computes the absolute value of a vector pointwise
Computes the acos of a vector pointwise
Computes the asin of a vector pointwise
Computes the atan of a vector pointwise
Computes the ceiling of a vector pointwise
Computes the cos of a vector pointwise
Computes the cosh of a vector pointwise
Computes the exponential of a vector pointwise
Computes the floor of a vector pointwise
Computes the log of a vector pointwise
Computes the log10 of a vector pointwise
Computes the rounded value of a vector pointwise
Computes the sin of a vector pointwise
Computes the sinh of a vector pointwise
Computes the sqrt of a vector pointwise
Computes the tan of a vector pointwise
Computes the tanh of a vector pointwise
Public Methods
T AbsoluteMaximum()
Returns the value of the absolute maximum element.
Return
T
The value of the absolute maximum element.
int AbsoluteMaximumIndex()
Returns the index of the absolute maximum element.
Return
int
The index of absolute maximum element.
T AbsoluteMinimum()
Returns the value of the absolute minimum element.
Return
T
The value of the absolute minimum element.
int AbsoluteMinimumIndex()
Returns the index of the absolute minimum element.
Return
int
The index of absolute minimum element.
Adds another vector to this vector and stores the result into the result vector.
Adds another vector to this vector.
Return
A new vector containing the sum of both vectors.
void Add(T scalar, Vector<T> result)
Adds a scalar to each element of the vector and stores the result in the result vector.
Adds a scalar to each element of the vector.
Parameters
T
scalar
Return
A copy of the vector with the scalar added.
T[] AsArray()
Returns the internal array of this vector if, and only if, this vector is stored by such an array internally.
Otherwise returns null. Changes to the returned array and the vector will affect each other.
Use ToArray instead if you always need an independent array.
T At(int index)
Gets the value at the given
index without range checking..
Parameters
int
index
Return
T
The value of the vector at the given index.
void At(int index, T value)
Sets the
value at the given
index without range checking..
Parameters
int
index
T
value
void Clear()
Resets all values to zero.
void ClearSubVector(int index, int count)
Sets all values of a subvector to zero.
Returns a deep-copy clone of the vector.
Return
A deep-copy clone of the vector.
void CoerceZero(Func<T, bool> zeroPredicate)
Set all values that meet the predicate to zero, in-place.
void CoerceZero(double threshold)
Set all values whose absolute value is smaller than the threshold to zero, in-place.
Return vector with complex conjugate values of the source vector
void Conjugate(Vector<T> result)
Complex conjugates vector and save result to
result
T ConjugateDotProduct(Vector<T> other)
Computes the dot product between the conjugate of this vector and another vector.
Return
T
The sum of conj(a[i])*b[i] for all i.
void CopySubVectorTo(Vector<T> destination, int sourceIndex, int targetIndex, int count)
Copies the requested elements from this vector to another.
Parameters
int
sourceIndex
int
targetIndex
int
count
void CopyTo(Vector<T> target)
Copies the values of this vector into the target vector.
void Divide(T scalar, Vector<T> result)
Divides each element of the vector by a scalar and stores the result in the result vector.
Divides each element of the vector by a scalar.
Parameters
T
scalar
Return
A new vector that is the division of the vector and the scalar.
void DivideByThis(T scalar, Vector<T> result)
Divides a scalar by each element of the vector and stores the result in the result vector.
Vector<T> DivideByThis(T scalar)
Divides a scalar by each element of the vector.
Parameters
T
scalar
Return
A new vector that is the division of the vector and the scalar.
T DotProduct(Vector<T> other)
Computes the dot product between this vector and another vector.
Return
T
The sum of a[i]*b[i] for all i.
IEnumerable<T> Enumerate()
Returns an IEnumerable that can be used to iterate through all values of the vector.
IEnumerable<T> Enumerate(Zeros zeros)
Returns an IEnumerable that can be used to iterate through all values of the vector.
IEnumerable<ValueTuple<int, T>> EnumerateIndexed(Zeros zeros)
Returns an IEnumerable that can be used to iterate through all values of the vector and their index.
IEnumerable<ValueTuple<int, T>> EnumerateIndexed()
Returns an IEnumerable that can be used to iterate through all values of the vector and their index.
bool Equals(object obj)
Determines whether the specified
Object is equal to this instance.
Parameters
object
obj
Return
bool
true
if the specified Object is equal to this instance; otherwise, false
.
bool Equals(Vector<T> other)
Indicates whether the current object is equal to another object of the same type.
Return
bool
true
if the current object is equal to the other parameter; otherwise, false
.
bool Exists(Func<T, bool> predicate, Zeros zeros)
Returns true if at least one element satisfies a predicate.
Zero elements may be skipped on sparse data structures if allowed (default).
bool Exists2<TOther>(Func<T, TOther, bool> predicate, Vector<T> other, Zeros zeros)
Returns true if at least one element pairs of two vectors of the same size satisfies a predicate.
Zero elements may be skipped on sparse data structures if allowed (default).
Tuple<int, T> Find(Func<T, bool> predicate, Zeros zeros)
Returns a tuple with the index and value of the first element satisfying a predicate, or null if none is found.
Zero elements may be skipped on sparse data structures if allowed (default).
Tuple<int, T, TOther> Find2<TOther>(Func<T, TOther, bool> predicate, Vector<T> other, Zeros zeros)
Returns a tuple with the index and values of the first element pair of two vectors of the same size satisfying a predicate, or null if none is found.
Zero elements may be skipped on sparse data structures if allowed (default).
TState Fold2<TOther, TState>(Func<TState, T, TOther, TState> f, TState state, Vector<T> other, Zeros zeros)
Applies a function to update the status with each value pair of two vectors and returns the resulting status.
bool ForAll(Func<T, bool> predicate, Zeros zeros)
Returns true if all elements satisfy a predicate.
Zero elements may be skipped on sparse data structures if allowed (default).
bool ForAll2<TOther>(Func<T, TOther, bool> predicate, Vector<T> other, Zeros zeros)
Returns true if all element pairs of two vectors of the same size satisfy a predicate.
Zero elements may be skipped on sparse data structures if allowed (default).
int GetHashCode()
Returns a hash code for this instance.
Return
int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
double InfinityNorm()
Calculates the infinity norm of the vector.
Return
double
The maximum absolute value.
double L1Norm()
Calculates the L1 norm of the vector, also known as Manhattan norm.
Return
double
The sum of the absolute values.
double L2Norm()
Calculates the L2 norm of the vector, also known as Euclidean norm.
Return
double
The square root of the sum of the squared values.
void Map(Func<T, T> f, Vector<T> result, Zeros zeros)
Applies a function to each value of this vector and replaces the value in the result vector.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
Vector<T> Map<TU>(Func<T, TU> f, Zeros zeros)
Applies a function to each value of this vector and returns the results as a new vector.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
Applies a function to each value pair of two vectors and returns the results as a new vector.
void Map2(Func<T, T, T> f, Vector<T> other, Vector<T> result, Zeros zeros)
Applies a function to each value pair of two vectors and replaces the value in the result vector.
void MapConvert<TU>(Func<T, TU> f, Vector<T> result, Zeros zeros)
Applies a function to each value of this vector and replaces the value in the result vector.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
void MapIndexed(Func<int, T, T> f, Vector<T> result, Zeros zeros)
Applies a function to each value of this vector and replaces the value in the result vector.
The index of each value (zero-based) is passed as first argument to the function.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
Vector<T> MapIndexed<TU>(Func<int, T, TU> f, Zeros zeros)
Applies a function to each value of this vector and returns the results as a new vector.
The index of each value (zero-based) is passed as first argument to the function.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
void MapIndexedConvert<TU>(Func<int, T, TU> f, Vector<T> result, Zeros zeros)
Applies a function to each value of this vector and replaces the value in the result vector.
The index of each value (zero-based) is passed as first argument to the function.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
void MapIndexedInplace(Func<int, T, T> f, Zeros zeros)
Applies a function to each value of this vector and replaces the value with its result.
The index of each value (zero-based) is passed as first argument to the function.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
void MapInplace(Func<T, T> f, Zeros zeros)
Applies a function to each value of this vector and replaces the value with its result.
If forceMapZero is not set to true, zero values may or may not be skipped depending
on the actual data storage implementation (relevant mostly for sparse vectors).
T Maximum()
Returns the value of maximum element.
Return
T
The value of maximum element.
int MaximumIndex()
Returns the index of the maximum element.
Return
int
The index of maximum element.
T Minimum()
Returns the value of the minimum element.
Return
T
The value of the minimum element.
int MinimumIndex()
Returns the index of the minimum element.
Return
int
The index of minimum element.
Vector<T> Modulus(T divisor)
Computes the canonical modulus, where the result has the sign of the divisor,
for each element of the vector for the given divisor.
Parameters
T
divisor
Return
A vector containing the result.
void Modulus(T divisor, Vector<T> result)
Computes the canonical modulus, where the result has the sign of the divisor,
for each element of the vector for the given divisor.
void ModulusByThis(T dividend, Vector<T> result)
Computes the canonical modulus, where the result has the sign of the divisor,
for the given dividend for each element of the vector.
Vector<T> ModulusByThis(T dividend)
Computes the canonical modulus, where the result has the sign of the divisor,
for the given dividend for each element of the vector.
Parameters
T
dividend
Return
A vector containing the result.
Vector<T> Multiply(T scalar)
Multiplies a scalar to each element of the vector.
Parameters
T
scalar
Return
A new vector that is the multiplication of the vector and the scalar.
void Multiply(T scalar, Vector<T> result)
Multiplies a scalar to each element of the vector and stores the result in the result vector.
void Negate(Vector<T> result)
Negates vector and save result to
result
Returns a negated vector.
Return
The negated vector.
double Norm(double p)
Computes the p-Norm.
Parameters
double
p
Return
double
Scalar ret = (sum(abs(this[i])^p))^(1/p)
Vector<T> Normalize(double p)
Normalizes this vector to a unit vector with respect to the p-norm.
Parameters
double
p
Return
This vector normalized to a unit vector with respect to the p-norm.
Computes the outer product M[i,j] = u[i]*v[j] of this and another vector and stores the result in the result matrix.
Computes the outer product M[i,j] = u[i]*v[j] of this and another vector.
void PointwiseAbs(Vector<T> result)
Pointwise applies the abs function to each value
Pointwise applies the abs function to each value
void PointwiseAbsoluteMaximum(Vector<T> other, Vector<T> result)
Pointwise applies the absolute maximum with the values of another vector to each value.
Vector<T> PointwiseAbsoluteMaximum(T scalar)
Pointwise applies the absolute maximum with a scalar to each value.
Parameters
T
scalar
Pointwise applies the absolute maximum with the values of another vector to each value.
void PointwiseAbsoluteMaximum(T scalar, Vector<T> result)
Pointwise applies the absolute maximum with a scalar to each value.
void PointwiseAbsoluteMinimum(Vector<T> other, Vector<T> result)
Pointwise applies the absolute minimum with the values of another vector to each value.
Pointwise applies the absolute minimum with the values of another vector to each value.
Vector<T> PointwiseAbsoluteMinimum(T scalar)
Pointwise applies the absolute minimum with a scalar to each value.
Parameters
T
scalar
void PointwiseAbsoluteMinimum(T scalar, Vector<T> result)
Pointwise applies the absolute minimum with a scalar to each value.
Pointwise applies the acos function to each value
void PointwiseAcos(Vector<T> result)
Pointwise applies the acos function to each value
void PointwiseAsin(Vector<T> result)
Pointwise applies the asin function to each value
Pointwise applies the asin function to each value
void PointwiseAtan(Vector<T> result)
Pointwise applies the atan function to each value
Pointwise applies the atan function to each value
Pointwise applies the atan2 function to each value of the current
vector and a given other vector being the 'x' of atan2 and the
'this' vector being the 'y'
Pointwise applies the atan2 function to each value of the current
vector and a given other vector being the 'x' of atan2 and the
'this' vector being the 'y'
void PointwiseCeiling(Vector<T> result)
Pointwise applies the ceiling function to each value
Vector<T> PointwiseCeiling()
Pointwise applies the ceiling function to each value
Pointwise applies the cos function to each value
void PointwiseCos(Vector<T> result)
Pointwise applies the cos function to each value
void PointwiseCosh(Vector<T> result)
Pointwise applies the cosh function to each value
Pointwise applies the cosh function to each value
Pointwise divide this vector with another vector.
Return
A new vector which is the pointwise division of the two vectors.
void PointwiseDivide(Vector<T> divisor, Vector<T> result)
Pointwise divide this vector with another vector and stores the result into the result vector.
void PointwiseExp(Vector<T> result)
Pointwise applies the exponent function to each value.
Pointwise applies the exponent function to each value.
Pointwise applies the floor function to each value
void PointwiseFloor(Vector<T> result)
Pointwise applies the floor function to each value
void PointwiseLog(Vector<T> result)
Pointwise applies the natural logarithm function to each value.
Pointwise applies the natural logarithm function to each value.
Pointwise applies the log10 function to each value
void PointwiseLog10(Vector<T> result)
Pointwise applies the log10 function to each value
void PointwiseMaximum(T scalar, Vector<T> result)
Pointwise applies the maximum with a scalar to each value.
Vector<T> PointwiseMaximum(T scalar)
Pointwise applies the maximum with a scalar to each value.
Parameters
T
scalar
Pointwise applies the maximum with the values of another vector to each value.
void PointwiseMaximum(Vector<T> other, Vector<T> result)
Pointwise applies the maximum with the values of another vector to each value.
void PointwiseMinimum(Vector<T> other, Vector<T> result)
Pointwise applies the minimum with the values of another vector to each value.
Pointwise applies the minimum with the values of another vector to each value.
void PointwiseMinimum(T scalar, Vector<T> result)
Pointwise applies the minimum with a scalar to each value.
Vector<T> PointwiseMinimum(T scalar)
Pointwise applies the minimum with a scalar to each value.
Parameters
T
scalar
Pointwise canonical modulus, where the result has the sign of the divisor,
of this vector with another vector.
void PointwiseModulus(Vector<T> divisor, Vector<T> result)
Pointwise canonical modulus, where the result has the sign of the divisor,
of this vector with another vector and stores the result into the result vector.
void PointwiseMultiply(Vector<T> other, Vector<T> result)
Pointwise multiplies this vector with another vector and stores the result into the result vector.
Pointwise multiplies this vector with another vector.
Return
A new vector which is the pointwise multiplication of the two vectors.
void PointwisePower(T exponent, Vector<T> result)
Pointwise raise this vector to an exponent and store the result into the result vector.
Vector<T> PointwisePower(T exponent)
Pointwise raise this vector to an exponent.
Parameters
T
exponent
Pointwise raise this vector to an exponent and store the result into the result vector.
void PointwisePower(Vector<T> exponent, Vector<T> result)
Pointwise raise this vector to an exponent.
Pointwise remainder (% operator), where the result has the sign of the dividend,
of this vector with another vector.
void PointwiseRemainder(Vector<T> divisor, Vector<T> result)
Pointwise remainder (% operator), where the result has the sign of the dividend,
this vector with another vector and stores the result into the result vector.
void PointwiseRound(Vector<T> result)
Pointwise applies the round function to each value
Pointwise applies the round function to each value
void PointwiseSign(Vector<T> result)
Pointwise applies the sign function to each value
Pointwise applies the sign function to each value
void PointwiseSin(Vector<T> result)
Pointwise applies the sin function to each value
Pointwise applies the sin function to each value
void PointwiseSinh(Vector<T> result)
Pointwise applies the sinh function to each value
Pointwise applies the sinh function to each value
void PointwiseSqrt(Vector<T> result)
Pointwise applies the sqrt function to each value
Pointwise applies the sqrt function to each value
void PointwiseTan(Vector<T> result)
Pointwise applies the tan function to each value
Pointwise applies the tan function to each value
void PointwiseTanh(Vector<T> result)
Pointwise applies the tanh function to each value
Pointwise applies the tanh function to each value
Vector<T> Remainder(T divisor)
Computes the remainder (vector % divisor), where the result has the sign of the dividend,
for each element of the vector for the given divisor.
Parameters
T
divisor
Return
A vector containing the result.
void Remainder(T divisor, Vector<T> result)
Computes the remainder (vector % divisor), where the result has the sign of the dividend,
for each element of the vector for the given divisor.
Vector<T> RemainderByThis(T dividend)
Computes the remainder (dividend % vector), where the result has the sign of the dividend,
for the given dividend for each element of the vector.
Parameters
T
dividend
Return
A vector containing the result.
void RemainderByThis(T dividend, Vector<T> result)
Computes the remainder (dividend % vector), where the result has the sign of the dividend,
for the given dividend for each element of the vector.
void SetSubVector(int index, int count, Vector<T> subVector)
Copies the values of a given vector into a region in this vector.
Parameters
int
index
int
count
void SetValues(T[] values)
Set the values of this vector to the given values.
Parameters
T[]
values
Subtracts another vector to this vector and stores the result into the result vector.
void Subtract(T scalar, Vector<T> result)
Subtracts a scalar from each element of the vector and stores the result in the result vector.
Subtracts another vector from this vector.
Return
A new vector containing the subtraction of the two vectors.
Vector<T> Subtract(T scalar)
Subtracts a scalar from each element of the vector.
Parameters
T
scalar
Return
A new vector containing the subtraction of this vector and the scalar.
void SubtractFrom(T scalar, Vector<T> result)
Subtracts each element of the vector from a scalar and stores the result in the result vector.
Vector<T> SubtractFrom(T scalar)
Subtracts each element of the vector from a scalar.
Parameters
T
scalar
Return
A new vector containing the subtraction of the scalar and this vector.
Vector<T> SubVector(int index, int count)
Creates a vector containing specified elements.
Parameters
int
index
int
count
Return
A vector containing a copy of the specified elements.
T Sum()
Computes the sum of the vector's elements.
Return
T
The sum of the vector's elements.
double SumMagnitudes()
Computes the sum of the absolute value of the vector's elements.
Return
double
The sum of the absolute value of the vector's elements.
T[] ToArray()
Returns the data contained in the vector as an array.
The returned array will be independent from this vector.
A new memory block will be allocated for the array.
Return
T[]
The vector's data as an array.
Create a matrix based on this vector in column form (one single column).
Return
This vector as a column matrix.
Create a matrix based on this vector in row form (one single row).
Return
This vector as a row matrix.
string ToString(int maxPerColumn, int maxCharactersWidth, string format, IFormatProvider provider)
Returns a string that summarizes this vector, column by column and with a type header.
Parameters
int
maxPerColumn
int
maxCharactersWidth
string
format
IFormatProvider
provider
string ToString()
Returns a string that summarizes this vector.
The maximum number of cells can be configured in the
Control class.
string ToString(string format, IFormatProvider formatProvider)
Returns a string that summarizes this vector.
The maximum number of cells can be configured in the
Control class.
The format string is ignored.
string ToTypeString()
Returns a string that describes the type, dimensions and shape of this vector.
string ToVectorString(int maxPerColumn, int maxCharactersWidth, string ellipsis, string columnSeparator, string rowSeparator, Func<T, string> formatValue)
Returns a string that represents the content of this vector, column by column.
Parameters
int
maxPerColumn
int
maxCharactersWidth
string
ellipsis
string
columnSeparator
string
rowSeparator
Func<T, string>
formatValue
string ToVectorString(int maxPerColumn, int maxCharactersWidth, string format, IFormatProvider provider)
Returns a string that represents the content of this vector, column by column.
Parameters
int
maxPerColumn
int
maxCharactersWidth
string
format
IFormatProvider
provider
string ToVectorString(string format, IFormatProvider provider)
Returns a string that represents the content of this vector, column by column.
Parameters
string
format
IFormatProvider
provider
String[,] ToVectorStringArray(int maxPerColumn, int maxCharactersWidth, int padding, string ellipsis, Func<T, string> formatValue)
Public Properties
int Count get; set;
Gets the length or number of dimensions of this vector.
T Item get; set;
Gets or sets the value at the given index.
Gets the raw vector data storage.
Public fields
T Zero
The zero value for type T.
T One
The value of 1.0 for type T.